package expressions;

import parsing.Parser;
import exceptions.EvaluationException;

/**
 * A token that plays some syntactic role in parsing an expression, but should
 * never end up in an expression tree. For this reason, an error is thrown if a
 * SyntaxElement is evaluated.
 * 
 * The default parsing methods for a SyntaxElement place it on the operator
 * stack, and then destroy it entirely when it is built from the operator stack
 * to the output. This should be appropriate for most syntax elements.
 */
public abstract class SyntaxElement<T> extends Expression<T>
{
    public SyntaxElement()
    {
    }

    public void parse(Parser<T> parser)
    {
        parser.addTopOperator(this);
    }

    @Override
    public T evaluate(IContext<T> context)
    {
        throw new EvaluationException();
    }

    @Override
    public void buildTree(Parser<T> parser)
    {
    }

}
